﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace dynamic.Project.Entity.Attrs
{
    /// <summary>
    /// 自定义Api方法，该方法只能实体类中，且必须是静态方法，否则不生效，
    /// 方法的形式参数必须是，(HttpContext ctx,DbAccess<T> acc)
    /// 返回值必须是ApiResult
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class ApiMethodAttribute : Attribute
    {
        public string Method { get; set; }
        public string Path { get; set; }

        public ApiMethodAttribute([CallerMemberName]string path = "",string method = "GET")
        {
            if(string.IsNullOrWhiteSpace(path))
                throw new Exception("自定义Api方法的注解路径参数不能为空");
            this.Path = path;
            this.Method = method;
        }
    }
}
